package com.longcai.service.impl.homepage;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.longcai.bean.ApiResult;
import com.longcai.entity.homepage.ClyjSeckillGoods;
import com.longcai.mapper.homepage.ClyjSeckillGoodsMapper;
import com.longcai.service.homepage.ClyjSeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 秒杀商品 服务实现类
 * </p>
 *
 * @author LWK
 * @since 2019-03-20
 */
@Service
public class ClyjSeckillGoodsServiceImpl extends ServiceImpl<ClyjSeckillGoodsMapper, ClyjSeckillGoods> implements ClyjSeckillGoodsService {

    @Autowired
    ClyjSeckillGoodsMapper seckillMapper;

    /**
     * description: 首页秒杀商品展示
     * author: LWK
     * time： 11点25分
     */
    @Override
    public ApiResult<List<Map<String, Object>>> getHomepageBannerList(JSONObject params) {
        ApiResult<List<Map<String, Object>>> result = new ApiResult<List<Map<String, Object>>>();
        try {
//			Date now = new Date();
//			SimpleDateFormat  format = new SimpleDateFormat("yyyy-MM-dd HH:ss:mm");
//			String format2 = format.format(now);
            String beginTime = params.getString("beginTime");
            //查询限时抢购物品列表
            List<Map<String, Object>> selectList = seckillMapper.selectGoodsById(beginTime);
            result.success();
            result.setData(selectList);
        } catch (Exception e) {
            e.printStackTrace();
            result.setCode("-1");
            result.fail("查询失败：" + e.getMessage());
        }
        return result;
    }

}
